#include <bits/stdc++.h>
using namespace std;
const int N = 5'000'000 + 10;
int a, b, t;
bool f[N] = {1};
int main() {
  cin >> t >> a >> b;
  // 吃柠檬
  for (int i = a; i <= t; ++i) f[i] |= f[i - a];
  // 吃橘子
  for (int i = b; i <= t; ++i) f[i] |= f[i - b];
  // 喝水，at most one time
  for (int i = 1; i <= t; ++i) f[i >> 1] |= f[i];
  // 继续吃柠檬
  for (int i = a; i <= t; ++i) f[i] |= f[i - a];
  // 继续吃橘子
  for (int i = b; i <= t; ++i) f[i] |= f[i - b];
  int ans = t;
  while (!f[ans]) ans--;
  cout << ans << endl;
}
